/**
 */
package de.thwildau.tm.moses.asn1.asn1.impl;

import de.thwildau.tm.moses.asn1.asn1.Asn1Package;
import de.thwildau.tm.moses.asn1.asn1.NumericRealValue;
import de.thwildau.tm.moses.asn1.asn1.RealSequenceValue;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Numeric Real Value</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.NumericRealValueImpl#getValue <em>Value</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.NumericRealValueImpl#getSequenceValue <em>Sequence Value</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class NumericRealValueImpl extends RealValueImpl implements NumericRealValue
{
  /**
   * The default value of the '{@link #getValue() <em>Value</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getValue()
   * @generated
   * @ordered
   */
  protected static final double VALUE_EDEFAULT = 0.0;

  /**
   * The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getValue()
   * @generated
   * @ordered
   */
  protected double value = VALUE_EDEFAULT;

  /**
   * The cached value of the '{@link #getSequenceValue() <em>Sequence Value</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSequenceValue()
   * @generated
   * @ordered
   */
  protected RealSequenceValue sequenceValue;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected NumericRealValueImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return Asn1Package.Literals.NUMERIC_REAL_VALUE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public double getValue()
  {
    return value;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setValue(double newValue)
  {
    double oldValue = value;
    value = newValue;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.NUMERIC_REAL_VALUE__VALUE, oldValue, value));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public RealSequenceValue getSequenceValue()
  {
    return sequenceValue;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetSequenceValue(RealSequenceValue newSequenceValue, NotificationChain msgs)
  {
    RealSequenceValue oldSequenceValue = sequenceValue;
    sequenceValue = newSequenceValue;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.NUMERIC_REAL_VALUE__SEQUENCE_VALUE, oldSequenceValue, newSequenceValue);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSequenceValue(RealSequenceValue newSequenceValue)
  {
    if (newSequenceValue != sequenceValue)
    {
      NotificationChain msgs = null;
      if (sequenceValue != null)
        msgs = ((InternalEObject)sequenceValue).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.NUMERIC_REAL_VALUE__SEQUENCE_VALUE, null, msgs);
      if (newSequenceValue != null)
        msgs = ((InternalEObject)newSequenceValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.NUMERIC_REAL_VALUE__SEQUENCE_VALUE, null, msgs);
      msgs = basicSetSequenceValue(newSequenceValue, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.NUMERIC_REAL_VALUE__SEQUENCE_VALUE, newSequenceValue, newSequenceValue));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case Asn1Package.NUMERIC_REAL_VALUE__SEQUENCE_VALUE:
        return basicSetSequenceValue(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case Asn1Package.NUMERIC_REAL_VALUE__VALUE:
        return getValue();
      case Asn1Package.NUMERIC_REAL_VALUE__SEQUENCE_VALUE:
        return getSequenceValue();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case Asn1Package.NUMERIC_REAL_VALUE__VALUE:
        setValue((Double)newValue);
        return;
      case Asn1Package.NUMERIC_REAL_VALUE__SEQUENCE_VALUE:
        setSequenceValue((RealSequenceValue)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.NUMERIC_REAL_VALUE__VALUE:
        setValue(VALUE_EDEFAULT);
        return;
      case Asn1Package.NUMERIC_REAL_VALUE__SEQUENCE_VALUE:
        setSequenceValue((RealSequenceValue)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.NUMERIC_REAL_VALUE__VALUE:
        return value != VALUE_EDEFAULT;
      case Asn1Package.NUMERIC_REAL_VALUE__SEQUENCE_VALUE:
        return sequenceValue != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (value: ");
    result.append(value);
    result.append(')');
    return result.toString();
  }

} //NumericRealValueImpl
